package com.nf.recruitment.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageInfo;
import com.nf.recruitment.dao.PostMapper;
import com.nf.recruitment.entity.PostInfo;
import com.nf.recruitment.dto.PostInfoDTO;
import com.nf.recruitment.dto.PostInfoPageDTO;
import com.nf.recruitment.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PostServiceImpl implements PostService {
    @Autowired
    private PostMapper postMapper;
    @Override
    public PostInfoPageDTO listPost(int pageNum, int pageSize) {
        List<PostInfoDTO> list = postMapper.listPost(pageNum, pageSize);
        PageInfo<PostInfoDTO> pageInfo = new PageInfo<>(list);
        PostInfoPageDTO pageDTO = BeanUtil.copyProperties(pageInfo, PostInfoPageDTO.class);
        return pageDTO;
    }

    @Override
    public void savePost(PostInfo postInfo) {
        postMapper.addPost(postInfo);
    }
}
